import Vue from 'vue';
//配置路由
import VueRouter from 'vue-router'
Vue.use(VueRouter);
//1.创建组件
import Index from '../views/index.vue'
import Home from '../views/home.vue'
import Login from '../views/login.vue'
import NotFound from '../views/404.vue'
import UpdatePassword from '../views/update-password.vue'
import pay from '../views/pay.vue'
import register from '../views/register.vue'
import center from '../views/center.vue'
    import forum from '../views/modules/forum/list'
    // import news from '../views/modules/news/list'
    // import discusskeyanxiangmu from '../views/modules/discusskeyanxiangmu/list'
    import xuesheng from '../views/modules/xuesheng/list.vue'
    import keyanxiangmu from '../views/modules/keyanxiangmu/list'
    import xiangmuchengguo from '../views/modules/xiangmuchengguo/list'
    import keyanbumen from '../views/modules/keyanbumen/list'
    // import discussxiangmuchengguo from '../views/modules/discussxiangmuchengguo/list'
    import xiangmucanyu from '../views/modules/xiangmucanyu/list'
    // import config from '../views/modules/list'
    import keyanleibie from '../views/modules/keyanleibie/list'


//2.配置路由   注意：名字
const routes = [{
    path: '/index',
    name: '系统首页',
    component: Index,
    children: [{
      // 这里不设置值，是把main作为默认页面
      path: '/',
      name: '系统首页',
      component: Home,
      meta: {icon:'', title:'center'}
    }, {
      path: '/updatePassword',
      name: '修改密码',
      component: UpdatePassword,
      meta: {icon:'', title:'updatePassword'}
    }, {
      path: '/pay',
      name: '支付',
      component: pay,
      meta: {icon:'', title:'pay'}
    }, {
      path: '/center',
      name: '个人信息',
      component: center,
      meta: {icon:'', title:'center'}
    }
      ,{
	path: '/forum',
        name: '科研论坛',
        component: forum
      }
  //     ,{
	// path: '/news',
  //       name: '科研公告',
  //       component: news
  //     }
  //     ,{
	// path: '/discusskeyanxiangmu',
  //       name: '科研项目评论',
  //       component: discusskeyanxiangmu
  //     }
      ,{
	path: '/xuesheng',
        name: '学生',
        component: xuesheng
      }
      ,{
	path: '/keyanxiangmu',
        name: '科研项目',
        component: keyanxiangmu
      }
      ,{
	path: '/xiangmuchengguo',
        name: '项目成果',
        component: xiangmuchengguo
      }
      ,{
	path: '/keyanbumen',
        name: '科研部门',
        component: keyanbumen
      }
  //     ,{
	// path: '/discussxiangmuchengguo',
  //       name: '项目成果评论',
  //       component: discussxiangmuchengguo
  //     }
      ,{
	path: '/xiangmucanyu',
        name: '项目参与',
        component: xiangmucanyu
      }
  //     ,{
	// path: '/config',
  //       name: '轮播图管理',
  //       component: config
  //     }
      ,{
	path: '/keyanleibie',
        name: '科研类别',
        component: keyanleibie
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: Login,
    meta: {icon:'', title:'login'}
  },
  {
    path: '/register',
    name: 'register',
    component: register,
    meta: {icon:'', title:'register'}
  },
  {
    path: '/',
    name: '系统首页',
    redirect: '/index'
  }, /*默认跳转路由*/
  {
    path: '*',
    component: NotFound
  }
]
//3.实例化VueRouter  注意：名字
const router = new VueRouter({
  mode: 'hash',
  /*hash模式改为history*/
  routes // （缩写）相当于 routes: routes
})
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}
export default router;
